<?php 

$data = $_POST;

//读数据库文件
$oldData = file_get_contents('./Db/user.txt');
//把json数据库数组
$oldData = json_decode($oldData,true);



foreach ($oldData as $k => $v) {
		
	if($v['email']==$data['email'] && $v['password']==md5($data['password'])){

		session_start();

		$_SESSION['id'] = $k;
		$_SESSION['username'] = $v['username'];

		echo json_encode(['error'=>0,'info'=>'登录成功']);exit;
	}
}

echo json_encode(['error'=>1,'info'=>'邮箱或者密码错误']);exit;






 ?>